#include "PlatformFactory.h"
#include "WindowsOpenGLES.h"

PlatformFactory * PlatformFactory::m_pInstance = NULL;
IPlatform * PlatformFactory::m_pPlatform = NULL;

PlatformFactory::PlatformFactory()
{
	LOGIDBG("Init PlatformFactory\n");
}

PlatformFactory::~PlatformFactory()
{
	LOGIDBG("Destroy PlatformFactory\n");
}

PlatformFactory * PlatformFactory::GetInstance()
{
	if (!m_pInstance)
		m_pInstance = new PlatformFactory();
	return m_pInstance;
}

void PlatformFactory::DestroyInstance()
{
	m_pPlatform->Destroy();
	SAFE_DEL(m_pPlatform);
	SAFE_DEL(m_pInstance);
}

IPlatform * PlatformFactory::CreatePlatform(FWuint id, FWuint iWidth, FWuint iHeight, char * szTitle, FWuint iFlags)
{
	m_pPlatform = NULL;
	switch (id)
	{
	case FW_WIN32_GLES_20:
		m_pPlatform = new WindowsOpenGLES(iWidth, iHeight, szTitle, iFlags);
		break;
	default:
		break;
	}
	return m_pPlatform;
}

IPlatform * PlatformFactory::GetCurrentPlatform()
{
	return m_pPlatform;
}